package com.chenj.springbootgrpcclient.config;

import com.chenj.springbootgrpcclient.interceptor.LogGrpcInterceptor;
import io.grpc.ClientInterceptor;
import net.devh.boot.grpc.client.interceptor.GrpcGlobalClientInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

/**
 * <p>
 * 为了让拦截类能够正常工作，即发起gRPC请求的时候被执行，需要新增一个配置类
 * </p>
 *
 * @since: 2022/8/13 17:52
 * @author: liyi
 */
@Order(Ordered.LOWEST_PRECEDENCE)
//@Configuration(proxyBeanMethods = false)
public class GlobalClientInterceptorConfiguration {

    @GrpcGlobalClientInterceptor
    ClientInterceptor logClientInterceptor() {
        return new LogGrpcInterceptor();
    }
}
